<script>
  $(document).ready(function(){
	  var category_del = $("#category_del").val();
      if(category_del==1){
           alert('此资料种类下还有资料版本，此资料种类不可以删除');
      }
     $("#mod_id").change(function(){
         $("#category_form").submit();
     })

     $(".export").click(function(){
         var export_mod = $("#export_mod").val();
         var name = $(this).val();
         var file = $("#file").val();
         
         if(export_mod==""){
             alert("请选择型号！");
             return false;
         }else{ 
           if(name=="下载模板"){
             $.ajax({
    	    	   type: "POST",
    	    	   url:"<?php echo  base_url();?>administrator/export",
    	    	   data: "export_mod="+export_mod+"&export="+name,
    	    	   success: function(msg){
        	    	   window.location.href="<?php echo base_url();?>img/template_"+export_mod+".xls";
    	    	   }
    	    	});
           }else{
              if(file==""){
                alert("请选择要导入的文件");
                return false;
              }
           }
         }
     })
  })
</script>
		<div id="center-column">
			<div class="top-bar">
				<a href="<?php echo  base_url();?>administrator/category_add" class="button">新增</a>
				<h1>Contents</h1>
				<div class="breadcrumbs"><?php echo anchor('main/index','首页');?> / <?php echo anchor('administrator/category','资料类别管理');?></div>
			</div><br />
		  <div class="select-bar" style="height:40px;">
		  <div style="float:left;"><?php echo form_open('administrator/category',array('id'=>'category_form'));?> 
		    <label>型号：</label><label><select id="mod_id" name="mod_id">
		                      <option value="">全部型号</option>
		                   <?php foreach($mod as $k=>$val){?>
		                      <option value="<?php echo $val->mod_id;?>" <?php if(isset($mod_id)&&($mod_id==$val->mod_id)){?>selected=true<?php }?>><?php echo $val->name;?></option>
		                   <?php }?>
		                 </select>
		    </label>
		  </form>	
		  </div>
<!-- 		  <div style="float:right;">
		  <?php echo form_open_multipart('administrator/export',array('id'=>'category_export'));?> 
			  <label>型号：</label><label><select id="export_mod" name="export_mod">
			                      <option value="">全部型号</option>
			                   <?php foreach($mod as $k=>$val){?>
			                      <option value="<?php echo $val->mod_id;?>"><?php echo $val->name;?></option>
			                   <?php }?>
			                 </select>
			                 <input type="button" name="export" value="下载模板" class="export" />
			    </label>
	            <label>
	  
	            <input type="file" name="category_export" id="file">
				<input type="submit" name="export" value="导入" class="export" />
				</label>
			</form>
			</div>
 -->			
		  </div>
			<div class="table">
				<input type="hidden" value="<?php echo $category_del;?>" id="category_del" >
				
				<table class="listing" cellpadding="0" cellspacing="0">
					<tr>
						<th class="first" width="22">ID</th>
						<th>型号</th>
						<th>资料编号</th>
						<th>资料名称</th>
						<th>密级</th>
						<th class="last">操作</th>
					</tr>
			    <?php foreach($category as $k=>$val):?>		
					<tr>
                        <td><?php echo $start;?></td>                        
                        <td><?php foreach($mod as $j=>$m){ if($val->mod_id==$m->mod_id){echo $m->name;}}?></td>
                        <td><?php echo $val->codes;?></td>
                        <td style="text-align:left;padding-left:5px;width:400px;"><?php echo $val->name;?></td>
                        <td><?php echo $level_data[$val->level];?></td>
                        <td><?php echo anchor('administrator/category_detail/'.$val->category_id,'查看',array('class'=>'category_detail'));?>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo anchor('administrator/category_edit/'.$val->category_id,'编辑',array('class'=>'mod_edit'));?>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo anchor('administrator/category_del/'.$val->category_id,'删除',array('class'=>'mod_edit',"onclick"=>"return confirm('您确定要删除吗？')?true:false;"));?></td>
					</tr>
				<?php $start++; endforeach;?>						
				</table>
				<?php echo $page;?>
			</div>
		</div>
	</div>
	<div id="footer"></div>
</div>


</body>
</html>
